import xadmin
from django.contrib.auth.models import AbstractUser
from django.db import models
import time

# Create your models here.
class Nav(models.Model): # 导航
    is_status = (
        ('0', '否'),
        ('1', '是')
    )
    name = models.CharField(verbose_name="导航名", max_length=250)
    status = models.CharField(choices=is_status,verbose_name="状态", max_length=200,default=1)
    sort = models.CharField(verbose_name="排序", max_length=200,default=0)
    father = models.ForeignKey('self', null = True, blank = True ,on_delete=models.CASCADE)
    path = models.CharField(verbose_name="方法路径",max_length=100)
    ctime = models.DateTimeField(verbose_name="创建时间",auto_now=True)
    class Meta:
        verbose_name = u'导航设置'
        verbose_name_plural = u"导航设置"

    def __str__(self):
        return self.name


class Carousel(models.Model):
    is_status = (
        ('0', '否'),
        ('1', '是')
    )
    name = models.CharField(verbose_name="名称", max_length=250)
    status = models.CharField(choices=is_status, verbose_name="状态", max_length=200, default=1)
    img = models.ImageField(verbose_name='图片',max_length=250, upload_to='carousel/{}/'.format(int(time.time())), blank=True)
    sort = models.CharField(verbose_name="排序", max_length=200, default=0)
    ctime = models.DateTimeField(verbose_name="创建时间",auto_now=True)
    uptime = models.DateTimeField(verbose_name="修改时间", auto_now=True)
    class Meta:
        verbose_name = u'轮播设置'
        verbose_name_plural = u"轮播设置"

    def __str__(self):
        return self.name